package sistema.validador;
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 29/3/2006 21:06:19
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   ValidatorCarriage.java

import java.io.*;

class ValidatorCarriage extends DiffIgnoreFileHeaderWhitespace
{

    public String diff_car(PushbackReader pr)
        throws IOException
    {
        StringBuffer sb;
label0:
        {
            boolean type = true;
            int c;
            char ch;
            do
            {
                c = pr.read();
                if(c == -1)
                    return null;
                ch = (char)c;
                if(c >= 32 && c <= 126 || c == 9)
                    type = false;
            } while(type);
            sb = new StringBuffer();
            sb.append(ch);
            do
            {
                c = pr.read();
                if(c == -1)
                    break label0;
                ch = (char)c;
                if((c < 32 || c > 126) && c != 9)
                    break;
                sb.append(ch);
            } while(true);
            pr.unread(c);
        }
        return sb.toString();
    }

    public void diffCar(FileReader fr, String temp1, PrintWriter log)
        throws IOException
    {
        BufferedReader br = new BufferedReader(fr);
        pr1 = new PushbackReader(br, 1);
        try
        {
            PrintWriter pw = new PrintWriter(new FileOutputStream(temp1), true);
            log.println("-------------------------*** START EXECUTION OF VALIDATOR CARRIAGE ***---------------------------");
            log.println("-------------------------***WRITING IN TEMP FILE (" + temp1 + ") TO WRITE***-----------------------");
            String token;
            while((token = diff_car(pr1)) != null) 
            {
                pw.println(token);
                log.println(token);
            }
        }
        catch(IOException e)
        {
            System.out.println("FAILED TO WRITE IN THE (" + temp1 + ") FILE " + e.toString());
            log.println("FAILED TO WRITE THE TEMP FILE (" + temp1 + ") " + e.toString());
        }
        log.println("-------------------------*** END EXECUTION OF VALIDATOR CARRIAGE ***---------------------------");
    }

    public ValidatorCarriage()
    {
    }

    private PushbackReader pr1;
}